import React from "react"
import {Input, message} from 'antd';
import { Select } from 'antd';
import './GoodsManage.css'
import { Button } from 'antd';
import GoodsManageTable from './GoodsManageTable'
import Axios from "axios";
import allApi from "../../../api/api.config";

const { Option } = Select;

class GoodsManage extends React.Component {
    //输入框查询
    researchGoods = e => {
        console.log(e);
        Axios.post('allApi.goodsApi.inputSearch',{
            pro_id:e.pro_id,
            pro_name:e.pro_name,
            limit:e.limit,
            name:e.name,
            num:e.num,
            page:e.page,
        }).then((res)=> {
            if(res.data.code===200) {
                this.success('查询成功')
            }else {
                this.error('加载出错,请联系管理员')
            }
        }).catch((err)=> {
            console.log(err);
        })
    }

    //选择查询
    handleChange = e => {
        console.log(e);
        message.success('查询成功');
        Axios.post('allApi.goodsApi.selectSearch',{
            pro_classify:e.pro_classify,
            limit:e.limit,
            page:e.page,
        }).then((res)=> {
            if(res.data.code===200) {
                this.success('查询成功')
            }else {
                this.error('加载出错,请联系管理员')
            }
        }).catch((err)=> {
            console.log(err);
        })
    }

    render() {
        return (
            <div>
                <div className="div1">
                    <h1>商品名称</h1>
                    <Input style={{ width: 180 }} placeholder="商品名称" onChange={this.researchGoods} />
                </div>
                <div className="div2">
                    <h1>商品货号</h1>
                    <Input style={{ width: 180 }} placeholder="商品货号" onChange={this.researchGoods} />
                </div>
                <div className="div3">
                    <h1>商品分类</h1>
                    <Select defaultValue="全部分类" style={{ width: 120 }}>
                        <Option value="全部分类">全部分类</Option>
                        <Option value="水果生鲜">水果生鲜</Option>
                        <Option value="食品粮油" >食品粮油</Option>
                        <Option value="其他分类">其他分类</Option>
                    </Select>
                    <Button type="primary" onClick={this.handleChange}>搜索</Button>
                </div>
                <GoodsManageTable></GoodsManageTable>
                {/*<Button type="primary">加入回收站</Button>*/}
            </div>
        )
    }
}

export {GoodsManage as default}